package com.qf.homeworkssm.intercepter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InteretorConfig implements WebMvcConfigurer {

    @Autowired
    LoginIntercepector loginIntercepector;

    @Autowired
    UserIntercepter userIntercepter;

    @Autowired
    AutoLogininterceptor autoLogininterceptor;


    /**
     * 添加自定义拦截器
     * @param registry
     */
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(myInterceptor)  // 拦截器对象
//                .addPathPatterns("/hi/**")  // 要拦截的路径
//                .excludePathPatterns("/hi/abc");  // 要放行的路径
//    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginIntercepector)
                .addPathPatterns("/plateform.html")
                .excludePathPatterns("/user/**");
        registry.addInterceptor(autoLogininterceptor)
                .excludePathPatterns("/login.html");
    }
}
